# -*- coding: utf-8 -*-
# @File : .py
# @Author : ZhouHang
# @Date : 18-8-21
# @Desc :

# 　自定义过滤器　
# from manage import app
import functools

from flask import current_app
from flask import g
from flask import session

from info.models import User


def choose(num):
    if num == 1:
        return 'first'
    elif num == 2:
        return 'second'
    elif num == 3:
        return 'third'
    else:
        return ''



def user_login_data(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        # 获取到当前登录用户的id
        user_id = session.get("user_id")
        # 通过id获取用户信息
        user = None
        if user_id:
            from info.models import User
            user = User.query.get(user_id)

        g.user = user
        return f(*args, **kwargs)
    return wrapper

